home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)P
/
(A)P1.ADF
/
Polygon
/
poly.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-05-25
|
4KB
|
155 lines
/* poly.c -- precompute x,y coordinates to speed drawing */
#include "lattice/stdio.h"
#include "lattice/math.h"
short int x1[50][15];
short int x2[50][27];
short int x3[50][51];
short int y1[50][15];
short int y2[50][27];
short int y3[50][51];
main()
{
register short int a,i,l,ls,n1,s;
double an,n;
FILE *fp;
for (a=0;a<50;a++){
ls=a+1;
for (i=0;i<3;i++){
switch (i) {
case 0:
an=PI/2.0;
s=0;
for (l=10;l<=20;l+=5){
x1[a][s]=(l*ls)/10;
y1[a][s]=0;
++s;
for (n=an;n<=(2*PI+.001);n+=an){
x1[a][s]=(short int)(l*(ls*cos(n))/10);
y1[a][s]=(short int)(ls*sin(n));
s++;
}
}
break;
case 1:
an=PI/4.0;
s=0;
for (l=10;l<=20;l+=5){
x2[a][s]=(l*ls)/10;
y2[a][s]=0;
++s;
for (n=an;n<=(2*PI+.001);n+=an){
x2[a][s]=(short int)(l*(ls*cos(n))/10);
y2[a][s]=(short int)(ls*sin(n));
s++;
}
}
break;
case 2:
an=PI/8.0;
s=0;
for (l=10;l<=20;l+=5){
x3[a][s]=(l*ls)/10;
y3[a][s]=0;
++s;
for (n=an;n<=(2*PI+.001);n+=an){
x3[a][s]=(short int)(l*(ls*cos(n))/10);
y3[a][s]=(short int)(ls*sin(n));
s++;
}
}
break;
}
}
}
fp = fopen("polynums.c","w");
fprintf (fp,"short int x1[50][15] = {\n\n");
for (a=0;a<50;a++){
if (a!=0)
fprintf(fp,"\t},\n\n");
fprintf(fp,"\t{\n");
for (n1=0;n1<15;n1++){
fprintf(fp,"\t%d",x1[a][n1]);
if (n1!=14)
fprintf(fp,",");
if (n1 % 7 == 6)
fprintf(fp,"\n");
}
}
fprintf (fp,"\t}\n};\n\n");
fprintf (fp,"short int y1[50][15] = {\n\n");
for (a=0;a<50;a++){
if (a!=0)
fprintf(fp,"\t},\n\n");
fprintf(fp,"\t{\n");
for (n1=0;n1<15;n1++){
fprintf(fp,"\t%d",y1[a][n1]);
if (n1!=14)
fprintf(fp,",");
if (n1 % 7 == 6)
fprintf(fp,"\n");
}
}
fprintf (fp,"\t}\n};\n\n");
fprintf (fp,"short int x2[50][27] = {\n\n");
for (a=0;a<50;a++){
if (a!=0)
fprintf(fp,"\t},\n\n");
fprintf(fp,"\t{\n");
for (n1=0;n1<27;n1++){
fprintf(fp,"\t%d",x2[a][n1]);
if (n1!=26)
fprintf(fp,",");
if (n1 % 7 == 6)
fprintf(fp,"\n");
}
}
fprintf (fp,"\t}\n};\n\n");
fprintf (fp,"short int y2[50][27] = {\n\n");
for (a=0;a<50;a++){
if (a!=0)
fprintf(fp,"\t},\n\n");
fprintf(fp,"\t{\n");
for (n1=0;n1<27;n1++){
fprintf(fp,"\t%d",y2[a][n1]);
if (n1!=26)
fprintf(fp,",");
if (n1 % 7 == 6)
fprintf(fp,"\n");
}
}
fprintf (fp,"\t}\n};\n\n");
fprintf (fp,"short int x3[50][51] = {\n\n");
for (a=0;a<50;a++){
if (a!=0)
fprintf(fp,"\t},\n\n");
fprintf(fp,"\t{\n");
for (n1=0;n1<51;n1++){
fprintf(fp,"\t%d",x3[a][n1]);
if (n1!=50)
fprintf(fp,",");
if (n1 % 7 == 6)
fprintf(fp,"\n");
}
}
fprintf (fp,"\t}\n};\n\n");
fprintf (fp,"short int y3[50][51] = {\n\n");
for (a=0;a<50;a++){
if (a!=0)
fprintf(fp,"\t},\n\n");
fprintf(fp,"\t{\n");
for (n1=0;n1<51;n1++){
fprintf(fp,"\t%d",y3[a][n1]);
if (n1!=50)
fprintf(fp,",");
if (n1 % 7 == 6)
fprintf(fp,"\n");
}
}
fprintf (fp,"\t}\n};\n\n");
fclose(fp);
}